﻿using OT.HikiSecureCenterApis.Req;
using OT.HikiSecureCenterApis.Res;
using OT.HikiSecureCenterApis.Service.Thermometric.Res;
using OT.HikiSecureCenterApis.Service.Video.Res;

namespace OT.HikiSecureCenterApis.Service.Thermometric
{
    public class ThermometricService : ServiceBase
    {
        public ThermometricService(HikiSecureCenterApis _SecureCenterApis) : base(_SecureCenterApis) { }

        /// <summary>
        /// 查询测温分组 /api/gptas/v1/group/search
        /// 支持分页查询创建的测温分组信息。
        /// </summary>
        /// <remarks>综合安防管理平台iSecure Center V1.5及以上版本</remarks>
        /// <param name="page">必填，页码、页大小</param>
        /// <param name="groupName">非必填，测温分组名称，支持模糊查询</param>
        /// <returns><see cref="ResAlarmInfoSearch"/></returns>
        public async Task<ResParameter<ResPageData<ResAlarmInfoSearch>>?> GroupSearchAsync(ReqPage page, string groupName = null) =>
          await SecureCenterApis.PostAsync<ResPageData<ResAlarmInfoSearch>>("/api/gptas/v1/group/search", 1.5, new
          {
              pageSize = page?.pageSize ?? 10,
              pageNo = page?.pageNo ?? 1,
              groupName = groupName
          });
        /// <summary>
        /// 查询测温点 /api/gptas/v1/thermodetector/search
        /// 支持分页查询添加到服务的测温点信息。
        /// </summary>
        /// <remarks>综合安防管理平台iSecure Center V1.5及以上版本</remarks>
        /// <param name="page">必填，页码、页大小</param>
        /// <param name="resourceName">非必填，资源名称，支持模糊查询</param>
        /// <param name="groupIds">非必填，测温分组id数组，从查询测温分组接口获取返回报文中的groupId字段</param>
        /// <param name="resourceCodes">非必填，	测温点code数组</param>
        /// <param name="resourceType">非必填，资源类型，1：视频，2门禁，不填则查询所有资源类型</param>
        /// <returns><see cref="ResThermodetectorSearch"/></returns>
        public async Task<ResParameter<ResPageData<ResThermodetectorSearch>>?> ThermodetectorSearchAsync(ReqPage page, string resourceName = null, IList<string> groupIds = null,
            IList<string> resourceCodes = null, int? resourceType = null) =>
          await SecureCenterApis.PostAsync<ResPageData<ResThermodetectorSearch>>("/api/gptas/v1/thermodetector/search", 1.5, new {
              pageSize = page?.pageSize ?? 10,
              pageNo = page?.pageNo ?? 1,
              resourceName = resourceName,
              groupIds = groupIds,
              resourceCodes = resourceCodes,
              resourceType = resourceType
          });
        /// <summary>
        /// 查询测温记录 /api/gptas/v1/alarmInfo/search
        /// 支持分页查询接收到的测温记录信息。
        /// </summary>
        /// <remarks>综合安防管理平台iSecure Center V1.5及以上版本</remarks>
        /// <param name="page">必填，页码、页大小、开始时间、结束时间</param>
        /// <param name="alarmId">非必填，测温记录id</param>
        /// <param name="resourceName">非必填，测温点名称，支持模糊查询</param>
        /// <param name="groupIds">非必填，测温分组id数组，从查询测温分组接口获取返回报文中的groupId字段</param>
        /// <param name="resourceCodes">非必填，温点编号数组，从查询测温点接口获取返回报文中的resourceCode字段</param>
        /// <param name="alarmType">非必填，报警类型，参考附录A.90 测温报警类型</param>
        /// <param name="sort">非必填，排序字段（支持resourceName、alarmTime填写排序的字段名称，例如：”alarmTime”）alarmTime：报警触发时间</param>
        /// <param name="order">非必填，升/降序（指定排序字段是使用升序（asc）还是降序（desc），例如：”asc”）</param>
        /// <returns><see cref="ResAlarmInfoSearch"/></returns>
        public async Task<ResParameter<ResPageData<ResAlarmInfoSearch>>?> AlarmInfoSearchAsync(ReqPageDate page,string alarmId = null, string resourceName = null,
            IList<string> groupIds = null, IList<string> resourceCodes = null, int? alarmType = null, string sort = null, string order = null) =>
          await SecureCenterApis.PostAsync<ResPageData<ResAlarmInfoSearch>>("/api/gptas/v1/alarmInfo/search", 1.5, new
          {
              pageSize = page?.pageSize ?? 10,
              pageNo = page?.pageNo ?? 1,
              startTime = page?.startTime,
              endTime = page?.endTime,
              alarmId = alarmId,
              resourceName = resourceName,
              resourceCodes = resourceCodes,
              groupIds = groupIds,
              alarmType = alarmType,
              sort = sort,
              order = order
          });
        /// <summary>
        /// 查询测温登记记录 /api/gptas/v1/register/search
        /// 支持分页查询登记人员信息。
        /// </summary>
        /// <remarks>综合安防管理平台iSecure Center V1.5及以上版本</remarks>
        /// <param name="page">必填，页码、页大小、开始时间、结束时间</param>
        /// <param name="alarmIds">非必填，测温记录id数组，从查询测温记录接口获取返回报文中的alarmId字段</param>
        /// <param name="resourceCodes">非必填，测温点编号数组，从查询测温点接口获取返回报文中的resourceCode字段</param>
        /// <param name="groupIds">非必填，测温分组id数组，从查询测温分组接口获取返回报文中的groupId字段</param>
        /// <param name="personName">非必填，人员姓名</param>
        /// <returns><see cref="ResRegisterSearch"/></returns>
        public async Task<ResParameter<ResPageData<ResRegisterSearch>>?> RegisterSearchAsync(ReqPageDate page, IList<string> alarmIds = null, IList<string> resourceCodes = null,
            IList<string> groupIds = null, string personName = null) =>
          await SecureCenterApis.PostAsync<ResPageData<ResRegisterSearch>>("/api/gptas/v1/register/search", 1.5, new
          {
              pageSize = page?.pageSize ?? 10,
              pageNo = page?.pageNo ?? 1,
              startTime = page?.startTime,
              endTime = page?.endTime,
              alarmIds = alarmIds,
              resourceCodes = resourceCodes,
              groupIds = groupIds,
              personName = personName
          });
        /// <summary>
        /// 获取测温事件的图片 /api/gptas/v1/events/picture
        /// 通过该接口根据输入的图片的相对Uri地址，可以获取到具体的数据数据。
        /// </summary>
        /// <remarks>综合安防管理平台iSecure Center V1.5及以上版本</remarks>
        /// <param name="svrIndexCode">非必填，存储接入服务（图片服务器唯一标识）</param>
        /// <param name="picUri">必填，图片uri</param>
        /// <returns><see cref="ResPicUrl"/></returns>
        public async Task<ResParameter<ResPicUrl>?> EventsPictureAsync(string svrIndexCode, string picUri) =>
          await SecureCenterApis.PostAsync<ResPicUrl>("/api/gptas/v1/events/picture", 1.5, new
          {
              svrIndexCode = svrIndexCode,
              picUri = picUri
          });
    }
}
